#include <stdio.h>
#include "SparseTableRMQ.h"

int main() {

	int size;
	vector<double> data;

	scanf("%d", &size);

	for ( int i = 0; i < size; ++i ) {
		double tmp = 0;
		scanf("%lf", &tmp);
		data.push_back(tmp);
	}

	SparseTableRMQ rmq = SparseTableRMQ(data);

	int a = 0;
	int b = 0;

	while (1) {

		scanf("%d%d", &a, &b );

		if ( (a >= 0) && (b < size) ) {
			printf("%lf\n", rmq.getRMQ(a, b));
		} else {
			printf("Out of range.\n");
		}
	}

	getchar();
	return 0;
}